# from sanic import
from sanic import  response,json,text,Blueprint,Sanic
from sanic_openapi import doc,openapi

bp = Blueprint('index', url_prefix='/')
app=Sanic.get_app()

@bp.route('/',methods=['GET'])
@openapi.tag('Index')
# @params_check({'task_id','process'})
# @doc.tag('index')
async def index(request):
    ''' 跳转至swagger 界面

    :param request:
    :return:
    '''
    # url=app.url_for('swagger.index')
        url = app.url_for('openapi.index')
    # return response.redirect(url)
    return response.redirect(url)

@bp.route('/index',methods=['GET'])
@openapi.tag('Index')
# @params_check({'task_id','process'})
# @doc.tag('index')
@openapi.summary('index-test')
async def index_test(request):
    ''' 
            index_test
    :param request:
    :return:
    '''
    return json({})



@bp.route('/index2',methods=['GET'])
@openapi.tag('Index')
# @params_check({'task_id','process'})
# @doc.tag('index')
@openapi.summary('index-test2')
@openapi.body(
    { "application/json" : RequestBody_Test },
    description="Body description",
    required=True,
)
async def index_test(request):
    ''' 
            index_test2
    :param request:
    :return:
    '''
    return json({})